import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Date: 2024-02-03
 * Time:22:57
 */
public class Solution {
/*
        public static class TreeNode {
            int val;
            TreeNode left;
            TreeNode right;

            TreeNode() {
            }

            TreeNode(int val) {
                this.val = val;
            }

            TreeNode(int val, TreeNode left, TreeNode right) {
                this.val = val;
                this.left = left;
                this.right = right;
            }

        }

        Stack<TreeNode> stack = new Stack<>();
        Queue<TreeNode> queue = new LinkedList<>();

        public List<List<Integer>> levelOrderBottom(TreeNode root) {
            if(root == null) {
                return new ArrayList<List<Integer>>();
            }
            List<List<Integer>> ret = new ArrayList<>();

            queue.offer(root);

            TreeNode cur = root;

            while(!queue.isEmpty()) {
                List<Integer> list = new ArrayList<>();
                int size = queue.size();

                while(size > 0) {
                    TreeNode top = queue.poll();
                    stack.push(top);
                    cur = top;

                    if(cur.right != null) {
                        queue.offer(cur.right);
                    }
                    if(cur.left != null) {
                        queue.offer(cur.left);
                    }

                    TreeNode pop = stack.pop();
                    list.add(pop.val);
                    size--;
                }
                ret.add(list);

            }
            return ret;
        }
*/
    }


